21. Exercise: Interface Communication

Define an Interface

In this exercise, you'll be defining an interface in the MasterListFragment class, and have it "callback" or communicate up to it's host activity.

Exercise Code

Exercise: TFragments.05-Exercise-InterfaceCommunication

Why interfaces?

To keep fragments modular and reusable, you cannot have them communicate directly with one another or directly tied to a host activity. An interface gives you a way to communicate but also stay modular because it can be implemented by any host activity -- this way the fragment is not tied directly to an activity.

Task Description:

Follow along with these tasks to implement fragment-to-activity communication.

Task List:

Task Feedback:

Excellent work!

Solution: [TFragments.05-Solution-InterfaceCommunication]

[Diff]